var Admin = require('./../controller/admin/admin');
var Auth = require('../auth/auth');
var express = require('express');
var router = express.Router();


/**
 * 渲染后台模版
 */

// login
router.get('/login', Admin.showLogin)
router.get('/logout', Admin.logout);
router.post('/login', Admin.admin_login);
// main 后台主页
router.get('/', Auth.loginRequired, Admin.showMain);
router.get('/home', Auth.loginRequired, Admin.showHome);
// 用户业务
router.get('/add_user/', Auth.loginRequired, Admin.showAddUser);
router.get('/update_user/:id', Auth.loginRequired, Admin.showUpdateUser);
router.post('/update_user', Auth.loginRequired, Admin.superAdmin, Admin.updateUser);
router.get('/user', Auth.loginRequired, Admin.showUser);
router.get('/user/:page', Auth.loginRequired, Admin.showUser);
router.post('/add_user', Auth.loginRequired, Admin.verifyName, Admin.superAdmin, Admin.addUser);
router.post('/del_user', Auth.loginRequired, Admin.superAdmin, Admin.delUser);
router.post('/del_more', Auth.loginRequired, Admin.superAdmin, Admin.delMoreUser);
router.post('/search_user', Auth.loginRequired, Admin.searchUser);
// 管理员业务
router.get('/admin_list', Auth.loginRequired, Admin.showAdmin);
router.post('/open_admin', Auth.loginRequired, Admin.superAdmin, Admin.openAdmin);
router.post('/del_admin', Auth.loginRequired, Admin.superAdmin, Admin.delAdmin);
router.post('/add_admin', Auth.loginRequired, Admin.superAdmin, Admin.addAdmin);
router.get('/add_admin', Auth.loginRequired, Admin.showAddAdmin);
router.post('/update_admin', Auth.loginRequired, Admin.superAdmin, Admin.updateAdmin);
router.get('/update_admin/:id', Auth.loginRequired, Admin.showUpdateAdmin);
// 留言业务
router.get('/message', Auth.loginRequired, Admin.showMessage);
router.get('/message/:page', Auth.loginRequired, Admin.showMessage);
router.post('/del_mess', Auth.loginRequired, Admin.superAdmin, Admin.delMessage);
router.post('/del_mess_more', Auth.loginRequired, Admin.superAdmin, Admin.delMoreMessage);
router.post('/search_message', Auth.loginRequired, Admin.searchMess);
// 评论业务
router.get('/comment', Auth.loginRequired, Admin.showComment);
router.get('/comment/:page', Auth.loginRequired, Admin.showComment);
router.post('/del_comment', Auth.loginRequired, Admin.superAdmin, Admin.delComment);
router.post('/del_comment_more', Auth.loginRequired, Admin.superAdmin, Admin.delMoreComment);
router.post('/search_comment', Auth.loginRequired, Admin.searchComment);

module.exports = router;
